<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:doc="livcos.org/ns/doc"
  xmlns="http://www.w3.org/1999/XSL/Format"
  exclude-result-prefixes="doc">

  <xsl:template match="doc:list">
    <list-block space-before="10pt" space-after="10pt">
      <xsl:if test="not(ancestor::doc:list)">
        <xsl:attribute name="margin-left">1cm</xsl:attribute>
      </xsl:if>
      <xsl:apply-templates select="doc:item" />
    </list-block>
  </xsl:template>

  <xsl:template match="doc:item">
    <list-item space-after="2pt">
      <list-item-label margin-left="0.2cm">
        <block font-family="serif">
          <xsl:variable name="level" select="count(ancestor::doc:list)"/>
          <xsl:choose>
            <xsl:when test="../@type = 'ordered'">
              <xsl:number /><xsl:text>.</xsl:text>
            </xsl:when>
            <xsl:when test="$level = 1">
              <xsl:text>&#x2022;</xsl:text>
            </xsl:when>
            <xsl:when test="$level = 2">
              <xsl:text>&#x2022;</xsl:text>
            </xsl:when>
            <xsl:when test="$level = 3">
              <xsl:text>&#x2022;</xsl:text>
            </xsl:when>
            <xsl:when test="$level = 4">
              <xsl:text>&#x2022;</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>&#x2022;</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </block>
      </list-item-label>
      <list-item-body>
        <block margin-left="0.5cm">
          <xsl:apply-templates />
        </block>
      </list-item-body>
    </list-item>
  </xsl:template>

</xsl:stylesheet>
